import { createRouter, createWebHistory } from 'vue-router'

import Demo from '../views/demo/index.vue'
import Home from '../views/home/index.vue'

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      name: 'home',
      path: '/',
      component: Home
    },
    {
      name: 'src',
      path: '/src/:path+',
      component: Home
    },
    {
      name: 'demo',
      path: '/demo/:path+',
      component: Demo
    }
  ]
})

// router.beforeEach((to, from, next) => {
//   console.warn(to, from)
//   if (to.fullPath.startsWith('/src')) {
//     next({name: 'home'})
//     // router.push({name: 'home', path: '/text/123'})
//   }
//   else next()
// })

export default router